import java.io.*;

/**
 * @author zyj
 * @date 2022年05月30日 16:15
 */
public class BufferedWriterDemo {
    public static void main(String[] args) {
        BufferedWriter writer = null;
        OutputStreamWriter osw = null;
        OutputStream os = null;
        try {
            os = new FileOutputStream("a.txt", true);
            osw = new OutputStreamWriter(os, "UTF-8");
            writer = new BufferedWriter(osw);
            writer.write("你好");
            //换行
            writer.newLine();
            writer.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                writer.close();
                osw.close();
                os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
